<?php

namespace CarApi\Controller;
use Think\Controller;
//use Common\RestController;
use Common\Model\CarLoginLogic;

class LoginController extends Controller {

	/**
	 * 登陆
	 * phone or plate_number , password
	 */
	public function login(){
		$carLoginModel = new CarLoginLogic;
		$res = $carLoginModel->login(I('account'),I('password'));
		if($res!==true){
			$this->ajaxReturn(['status'=>0,'error_info'=>$res]);
		}

		//获取登陆成功后的用户token
		$token = $carLoginModel->getLoginToken();
		$userId = $carLoginModel->getUserId();
		$plate_number = $carLoginModel->getPlateNumber();
		$this->ajaxReturn(['status'=>1,'data'=>['token'=>$token,'user_id'=>$userId,'plate_number'=>$plate_number]]);
	}

    
}